package day05;

import java.util.Arrays;

public class SelectionSort_02 {
    public static void main(String[] args) {
        int[] arr = new int[10];
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            arr[i] = (int) (Math.random() * 100 + 1);
        }
        System.out.println(Arrays.toString(arr));

        for (int j = 0; j < n - 1; j++){
            int maxIndex = j;
            for(int i = j + 1; i < n; i++){
                if (arr[i] > arr[maxIndex]){
                    maxIndex = i;
                }
            }
            int temp = arr[j];
            arr[j] = arr[maxIndex];
            arr[maxIndex] = temp;

        }
        System.out.println(Arrays.toString(arr));

    }

}
